package com.axialproject.health.exchange.entity;

public enum Race {

    WHITE (0, "White"),
    AFRICAN (1, "African"),
    HISPANIC   (2, "Hispanic"),
    ASIAN      (3, "Asian");

    private final int ordinalValue;
    private final String name;

    private Race (int ordinalValue, String name){
        this.ordinalValue = ordinalValue;
        this.name = name;
    }

    public static Race fromInt(int value) {
        switch(value) {
            case 0:  return Race.WHITE;
            case 1:  return Race.AFRICAN;
            case 2:  return Race.HISPANIC;
            case 3:  return Race.ASIAN;
            default: return Race.WHITE;
        }
    }

    public static Race fromName(String name) {
        if (Race.WHITE.getName().equals(name)) {
            return Race.WHITE;
        } else if (Race.AFRICAN.getName().equals(name)) {
            return Race.AFRICAN;
        } else if (Race.HISPANIC.getName().equals(name)) {
            return Race.HISPANIC;
        } else if (Race.ASIAN.getName().equals(name)) {
            return Race.ASIAN;
        } else {
            return Race.WHITE;
        }
    }

    public int getOrdinalValue() {
        return ordinalValue;
    }

    public String getName() {
        return name;
    }
}
